<script>
import { nextTick } from 'vue';
 
export default {
    data() {
        return {
            isRouterAlive: true
        }
    },
    methods: {
        reload() {
            this.isRouterAlive = false;
            nextTick(()=>{
                this.isRouterAlive = true;
            });
        }
    },
    provide(){
        return {
            reload: this.reload
        }
    }
}
</script>
 
<template>
    <div class="admin-container">
        <div class="admin-sidebar">
            <div class="admin-logo">
                <h2>系统管理</h2>
            </div>
            <nav class="admin-nav">
                <router-link to="/admin/user" class="nav-item">
                    <i class="fas fa-users"></i>
                    <span>用户管理</span>
                </router-link>
                <router-link to="/admin/bookings" class="nav-item">
                    <i class="fas fa-calendar-check"></i>
                    <span>预约管理</span>
                </router-link>
                <router-link to="/admin/comments" class="nav-item">
                    <i class="fas fa-comments"></i>
                    <span>评论管理</span>
                </router-link>
            </nav>
        </div>
        <div class="admin-content">
            <router-view></router-view>
        </div>
    </div>
</template>
 
<style scoped>
.admin-container {
    display: flex;
    min-height: 100vh;
    background-color: #f5f7fa;
}

.admin-sidebar {
    width: 240px;
    background-color: #304156;
    color: #fff;
    padding: 20px 0;
}

.admin-logo {
    padding: 0 20px;
    margin-bottom: 30px;
}

.admin-logo h2 {
    margin: 0;
    font-size: 20px;
    color: #fff;
}

.admin-nav {
    display: flex;
    flex-direction: column;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: #bfcbd9;
    text-decoration: none;
    transition: all 0.3s;
}

.nav-item:hover {
    color: #fff;
    background-color: #263445;
}

.nav-item.router-link-active {
    color: #409eff;
    background-color: #263445;
}

.nav-item i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

.admin-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}
</style>